package com.zhouyer.study.logindemo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * 首页面
 *
 * @author zhouyao
 * @version 1.0
 * @date 2021/9/19 5:40 下午
 */
@Controller
public class HomeController {
    @ResponseBody
    @GetMapping("/test")
    public String test() {
        return "test";
    }

    @GetMapping("/index")
    public String index(Map<String, Object> map, HttpServletRequest request, HttpSession session) {
        map.put("username", session.getAttribute("username"));
        map.put("port", request.getLocalPort());
        map.put("sessionId", session.getId());
        return "index";
    }
}
